const { TRANSITION_CONFIG } = require('../config/constants');

// 验证转场效果
function validateTransition(transition) {
    if (!TRANSITION_CONFIG.validTransitions.includes(transition)) {
        throw new Error(`无效的转场效果: ${transition}`);
    }
    return true;
}

// 验证图片URL数组
function validateImageUrls(imageUrls) {
    if (!imageUrls || !Array.isArray(imageUrls) || imageUrls.length < 2) {
        throw new Error('请提供至少两张图片的URL');
    }
    return true;
}

// 验证视频配置
function validateVideoConfig(config) {
    const {
        transition,
        duration,
        offset,
        fps,
        width,
        height,
        totalDuration
    } = config;

    // 验证转场效果
    validateTransition(transition);

    // 验证其他参数
    if (duration <= 0) throw new Error('转场持续时间必须大于0');
    if (offset < 0) throw new Error('转场偏移量不能为负数');
    if (fps <= 0) throw new Error('帧率必须大于0');
    if (width <= 0) throw new Error('宽度必须大于0');
    if (height <= 0) throw new Error('高度必须大于0');
    if (totalDuration <= 0) throw new Error('总时长必须大于0');

    return true;
}

module.exports = {
    validateTransition,
    validateImageUrls,
    validateVideoConfig
}; 